package com.glorystone.ins.dao;

import com.glorystone.ins.common.common.PageVo;
import com.glorystone.ins.common.common.Pageable;
import com.glorystone.ins.domain.Order;
import com.glorystone.ins.domain.SysUser;
import com.glorystone.ins.interceptor.PageList;
import com.glorystone.ins.vo.OrderViewVO;
import com.glorystone.ins.vo.OrderVo;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

public interface OrderMapper {
    int deleteByPrimaryKey(Long tid);

    int insert(Order record);

    int insertSelective(Order record);

    Order selectByPrimaryKey(Long tid);

    int selectByordCode(@Param("ordCode") String ordCode);

    int updateOrderSelective(Order record);

    int updateOrderSelectiveById(Order record);

    int updateByPrimaryKey(Order record);

    List<Order> findOrderList(@Param("channelId") String channelId, @Param("ordNum") String ordNum, @Param("insurant") String insurant, @Param("insureStartDate") Date insureStartDate);

    //报表导出
    List<OrderVo> findOrderVoExportList(@Param("channelId") Long channelId,
                                        @Param("ordNum") String ordNum, @Param("insurant") String insurant,
                                        @Param("insureStartDate") Date insureStartDate, @Param("status") Integer status);

    Order findOrderByCode(@Param("ordercode") String ordercode);

    OrderVo findOrderVoByCode(@Param("channelId") Long tid, @Param("tid") String ordCode);

    /**
     * 保险公司已结算订单
     *
     * @param insurerIds
     * @param vo
     * @return
     */
    PageList<OrderVo> getInsyrerDataOrderData(@Param("insurerIds") String insurerIds, @Param("vo") PageVo vo, Pageable pageable);

    PageList<OrderViewVO> selectOrderList(@Param("vo") PageVo vo, Pageable pageable);

    //订单列表查询及分页
    PageList<OrderVo> findOrderVoList(@Param("chanId") Long tid, @Param("vo") PageVo vo, Pageable pageable);

    /**
     * 渠道已结算订单
     *
     * @param vo
     * @return
     */
    PageList<OrderVo> getChannelDataOrderData(@Param("insurerIds") String insurerIds, @Param("vo") PageVo vo, Pageable pageable);

    List<OrderVo> findAlreadPayCompany(@Param("user") SysUser user, @Param("insyrerId") String insyrerId, @Param("ordNum") String ordNum,
                                       @Param("channelId") String channelId, @Param("insureStartDate") String insureStartDate,
                                       @Param("insureEndDate") String insureEndDate, @Param("plateNum") String plateNum);

    List<OrderVo> findAlreadPayChannel(@Param("user") SysUser user, @Param("insyrerId") String insyrerId, @Param("ordNum") String ordNum,
                                       @Param("channelId") String channelId, @Param("insureStartDate") String insureStartDate,
                                       @Param("insureEndDate") String insureEndDate, @Param("plateNum") String plateNum);

    List<OrderViewVO> downLoadNeedPay(@Param("user") SysUser user, @Param("insurerId1") Long insurerId1, @Param("plateNum1") String plateNum1,
                                      @Param("channelId1") String channelId1, @Param("themeKey") Integer themeKey, @Param("orderStatus") Integer orderStatus);

    //完善保单
    int updateByOrdCode(Order order);

    List<OrderViewVO> dwChannelNeedPay(@Param("user") SysUser user, @Param("insurerId2") Long insurerId2, @Param("plateNum2") String plateNum2, @Param("channelId2") String channelId2,
                                       @Param("insurantStartDate") String insurantStartDate,@Param("insurantEndDate") String insurantEndDate);

    //验证保单号唯一
    Order onlyOrdNum(String ordNum);

    PageList<OrderVo> findOrderVoListAll(@Param("vo") PageVo vo, Pageable pageable);
}